#动作相似度计算
'''import numpy as np
import math

#image
image = np.array([103.43478261 , 41.84782609, 107.41304348 , 65.76086957  ,87.52173913,
  71.73913043 , 75.58695652, 101.63043478 , 91.5   ,     125.54347826,
 127.30434783 , 65.76086957 ,135.26086957, 101.63043478, 107.41304348,
 125.54347826 , 91.5    ,    137.5    ,     91.5    ,    197.2826087,
  87.52173913, 251.08695652 ,115.36956522 ,143.47826087 ,119.34782609,
 191.30434783, 119.34782609 ,251.08695652 , 99.45652174,  35.86956522,
 107.41304348 , 35.86956522,  95.47826087 , 35.86956522, 115.36956522,
  35.86956522, 175.04347826  , 5.97826087])

sum0_1 = sum0_2 = 0
for i in range(0,len(image),2):
    sum0_1 += image[i]
average0_1 = float(sum0_1 / 19)
for i in range(0,len(image),2):
    image[i] = image[i] - average0_1

for j in range(1,len(image),2):
    sum0_2 += image[j]
average0_2 = float(sum0_2 / 19)
for j in range(1,len(image),2):
    image[j] = image[j] - average0_2
print(image)
#img = image.reshape(-1)
#print(img)

#image8
image8 = np.array([293.65217391, 106.7826087 , 293.65217391, 173.52173913 ,240.26086957,
 186.86956522 ,240.26086957 ,293.65217391, 253.60869565 ,360.39130435,
 333.69565217, 173.52173913, 360.39130435, 280.30434783, 320.34782609,
 106.7826087 , 266.95652174 ,360.39130435 ,240.26086957 ,427.13043478,
 253.60869565, 440.47826087 ,333.69565217, 347.04347826 ,347.04347826,
 427.13043478 ,253.60869565 ,440.47826087, 280.30434783 ,106.7826087 ,
 293.65217391 , 93.43478261 ,280.30434783 ,106.7826087 , 320.34782609,
 106.7826087  ,587.30434783 , 13.34782609])

sum8_1 = sum8_2 = 0
for i in range(0,len(image8),2):
    sum8_1 += image8[i]
average8_1 = float(sum8_1 / 19)
#print(average8_1)
for i in range(0,len(image8),2):
    image8[i] = image8[i] - average8_1
print(image8[0])
for j in range(1,len(image8),2):
    sum8_2 += image8[j]
average8_2 = float(sum8_2 / 19)
for j in range(1,len(image8),2):
    image8[j] = image8[j] - average8_2
print(image8)
#img8 = image8.reshape(-1)
#print(img8)

#image9
image9 = np.array([ 417.39130435,  286.95652174 , 417.39130435,  391.30434783  ,347.82608696,
  391.30434783 , 295.65217391 , 495.65217391  ,313.04347826 , 573.91304348,
  486.95652174 , 391.30434783 , 521.73913043  ,495.65217391,  486.95652174,
  600.00,          365.2173913 ,  600.00,          330.43478261 , 808.69565217,
  313.04347826,  991.30434783 , 452.17391304 , 626.08695652 , 469.56521739,
  808.69565217 , 486.95652174 ,1017.39130435,  400.00,          260.86956522,
  417.39130435,  286.95652174  ,382.60869565 , 286.95652174 , 452.17391304,
  286.95652174 , 765.2173913    ,26.08695652])

sum9_1 = sum9_2 = 0
for i in range(0,len(image9),2):
    sum9_1 += image9[i]
average9_1 = float(sum9_1 / 19)
for i in range(0,len(image9),2):
    image9[i] = image9[i] - average9_1

for j in range(1,len(image9),2):
    sum9_2 += image9[j]
average9_2 = float(sum9_2 / 19)
for j in range(1,len(image9),2):
    image9[j] = image9[j] - average9_2
 
#img9 = image9.reshape(-1)
#print(img9)


# 计算余弦相似度
#image and image8
sum08 = 0
sq0 = 0
sq8 = 0
for i in range(len(image)):
	sum08 += image[i] * image8[i]
	sq0 += pow(image[i], 2)
	sq8 += pow(image8[i], 2)
    
try:
	result08 = round(float(sum08) / (math.sqrt(sq0) * math.sqrt(sq8)), 2)
except ZeroDivisionError:
    result08 = 0.0

print('The similarity between image and image8 is')
print(result08)

#image and image9
sum09 = 0
#sq0 = 0
sq9 = 0
for i in range(len(image)):
	sum09 += image[i] * image9[i]
	#sq0 += pow(img[i], 2)
	sq9 += pow(image9[i], 2)
    
try:
	result09 = round(float(sum09) / (math.sqrt(sq0) * math.sqrt(sq9)), 2)
except ZeroDivisionError:
    result09 = 0.0

print('The similarity between image and image9 is')
print(result09)'''


import numpy as np
import math
from funtion import vector_centerpoint
from funtion import similarity
from funtion import video_brodcast

image = np.array([103.43478261 , 41.84782609, 107.41304348 , 65.76086957  ,87.52173913,
  71.73913043 , 75.58695652, 101.63043478 , 91.5   ,     125.54347826,
 127.30434783 , 65.76086957 ,135.26086957, 101.63043478, 107.41304348,
 125.54347826 , 91.5    ,    137.5    ,     91.5    ,    197.2826087,
  87.52173913, 251.08695652 ,115.36956522 ,143.47826087 ,119.34782609,
 191.30434783, 119.34782609 ,251.08695652 , 99.45652174,  35.86956522,
 107.41304348 , 35.86956522,  95.47826087 , 35.86956522, 115.36956522,
  35.86956522, 175.04347826  , 5.97826087])

vector_centerpoint(image)

image8 = np.array([293.65217391, 106.7826087 , 293.65217391, 173.52173913 ,240.26086957,
 186.86956522 ,240.26086957 ,293.65217391, 253.60869565 ,360.39130435,
 333.69565217, 173.52173913, 360.39130435, 280.30434783, 320.34782609,
 106.7826087 , 266.95652174 ,360.39130435 ,240.26086957 ,427.13043478,
 253.60869565, 440.47826087 ,333.69565217, 347.04347826 ,347.04347826,
 427.13043478 ,253.60869565 ,440.47826087, 280.30434783 ,106.7826087 ,
 293.65217391 , 93.43478261 ,280.30434783 ,106.7826087 , 320.34782609,
 106.7826087  ,587.30434783 , 13.34782609])


'''image8 = np.array([ 56.86956522,    0.00,           18.95652174,    0.00,          834.08695652,
 1652.2826087,   815.13043478 ,1615.56521739 , 834.08695652, 1615.56521739,
  815.13043478  , 36.7173913   ,834.08695652 ,1615.56521739 , 815.13043478,
   36.7173913   ,  0.00     ,       0.00,          853.04347826 ,1578.84782609,
  815.13043478  , 73.43478261 , 834.08695652 ,1578.84782609,  853.04347826,
 1615.56521739 , 815.13043478 ,1578.84782609, 815.13043478  , 36.7173913,
  815.13043478, 1542.13043478   , 0.00,            0.00,          834.08695652,
 1321.82608696 , 815.13043478  ,  0.00        ])'''

vector_centerpoint(image8)
video_brodcast(image,image8)